class Scdoc < Formula
  desc "Small man page generator"
  homepage "https://git.sr.ht/~sircmpwn/scdoc/"
  url "https://git.sr.ht/~sircmpwn/scdoc/archive/1.9.4.tar.gz"
  sha256 "a10e200bcbc7d6faf9678444636886fee2fd99c754b630fc62fa9d247f1eec03"

  bottle do
    cellar :any_skip_relocation
    sha256 "cfb73c0d39accbf6eae291c070ef32fab2694624d4584130c4863bd661327504" => :mojave
    sha256 "4afd3ea674eda6175220fa705faf48274f6d44d339875f334dee3b06927a4b27" => :high_sierra
    sha256 "c7e8ae0d4130bfcb022317d91927985c8c6a03a61a6df81a18a4e8dd79454720" => :sierra
  end

  def install
    # scdoc sets by default LDFLAGS=-static which doesn't work on macos(x)
    system "make", "LDFLAGS=", "PREFIX=#{prefix}"
    system "make", "install", "PREFIX=#{prefix}"
  end

  test do
    preamble = <<~'EOF'
      .\" Generated by scdoc 1.9.4
      .ie \n(.g .ds Aq \(aq
      .el       .ds Aq '
      .nh
      .ad l
      .\" Begin generated content:
    EOF
    assert_equal preamble, shell_output("#{bin}/scdoc </dev/null")
  end
end
